import {
	sub
} from '@/common/event.js'
import store from '@/store/index.js'
import moment from 'moment'
import {
	getRqst
} from '../../common/request'

export default {
	namespaced: true,
	state: {
		status: false,
		initstatus:false
	},
	mutations: {
		setConnectState: (state, payload) => {
			state.status = payload
		},
		setInitConnectState: (state, payload) => {
			state.initstatus = payload
		},
	},
	actions: {
		async init({
			commit,
			state
		}, {
			payload
		}) {


		}
	},
	init: async function() {
		const websocket = require("../../common/websocket.js")
		const user = uni.getStorageSync("user")
		if (user && user.id) {
			websocket.init(user.id)
		}
		sub("loginSuccess", function(e) {
			websocket.init(e.id)
		})
	}
}